/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tpgen.grammar;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 *
 * @author shanki
 */
public class RandomVariable implements Symbol {

    private String typeName;

    public RandomVariable(String typeName) {
        this.typeName   = typeName;
    }
    
    @Override
    public boolean isUsable() {
        return true;
    }    
    
    @Override
    public Collection<Symbol> expand(Context context) {
        List<Symbol> sym    = new ArrayList<Symbol>();
        sym.add(context.getRandomVariable(this));
        return sym;
    }

    @Override
    public String toUserString() {
        return "";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof RandomVariable) {
            return typeName.equals(((RandomVariable)obj).typeName);
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 13 * hash + (this.typeName != null ? this.typeName.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return typeName;
    }
    
}
